import java.util.Scanner;

public class Demo {

        public static int func(String str1,String str2) {

            int len1 = str1.length();
            int len2 = str2.length();


            int[][] array = new int[len1+1][len2+1];
            for(int i = 0; i <= len1; i++) {
                array[i][0] = i;
            }

            for(int j = 0; j <= len2; j++) {
                array[0][j] = j;
            }

            for(int i = 1; i <= len1; i++) {
                char ch = str1.charAt(i-1);
                for(int j = 1; j <= len2; j++) {
                    char cs = str2.charAt(j-1);
                    //插入和删除选择一个最小值
                    array[i][j] = Math.min(array[i-1][j],array[i][j-1])+1;

                    //修改的两种情况
                    //1.相等不变
                    //2.不相等改变
                    if(ch == cs) {
                        array[i][j] = Math.min(array[i][j],array[i-1][j-1]);
                    }else {
                        array[i][j] = Math.min(array[i][j],array[i-1][j-1]+1);
                    }
                }
            }

            return array[len1][len2];
        }

        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);

            while(scan.hasNextLine()) {
                String str1 = scan.nextLine();
                String str2 = scan.nextLine();
                System.out.println(func(str1,str2));
            }
        }
    }
